package cn.hashq.netpoststation.controller;

import cn.hashq.netpoststation.dto.AddPortMapDTO;
import cn.hashq.netpoststation.service.PortMapManagerService;
import cn.hashq.netpoststation.vo.ServerResponse;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/port")
public class PortMapController {

    @Resource
    private PortMapManagerService portMapManagerService;

    @PutMapping("")
    public ServerResponse addPortMap(@RequestBody AddPortMapDTO dto) {
        return portMapManagerService.addPortMap(dto);
    }

    @GetMapping("/ports")
    public ServerResponse listPortMap() {
        return portMapManagerService.listPortMap();
    }

    @PostMapping("/{id}")
    public ServerResponse notifyPortMapStatus(@PathVariable Long id){
        return portMapManagerService.notifyPortMapStatus(id);
    }

    @DeleteMapping("/{id}")
    public ServerResponse removePortMap(@PathVariable Long id) {
        return portMapManagerService.removePortMap(id);
    }

}
